<?php
// +----------------------------------------------------------------------
// | QSCMS
// +----------------------------------------------------------------------
// | Copyright (c)  2025 https://www.qqss.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed QSCMS is not free software, commercial use must purchase official license from official website to avoid unnecessary legal disputes.
// +----------------------------------------------------------------------
// | Author: Contract 990504246@qq.com
// +----------------------------------------------------------------------

namespace app\adminapi\validate\user;

use app\adminapi\validate\Base;

class VipValidate extends Base
{
    protected $rule = [
        'id'                => 'require',
        'name'              => 'require|max:50',
        'icon'              => 'max:255',
        'price'             => 'require|float|egt:0',
        'duration'          => 'require|number|egt:1',
        'exclusive_content' => 'in:0,1',
        'description'       => 'max:1000',
        'status'            => 'in:0,1',
        'points_reward'     => 'number|egt:0',
        'user_id'           => 'require|number',
        'vip_id'            => 'require|number',
        'record_id'         => 'require|number',
    ];

    protected $message = [
        'id.require'           => 'id_required',
        'name.require'         => 'vip_name_required',
        'name.max'             => 'vip_name_max',
        'icon.max'             => 'icon_max',
        'price.require'        => 'price_required',
        'price.float'          => 'price_float',
        'price.egt'            => 'price_egt',
        'duration.require'     => 'duration_required',
        'duration.number'      => 'duration_number',
        'duration.egt'         => 'duration_egt',
        'exclusive_content.in' => 'exclusive_content_in',
        'description.max'      => 'description_max',
        'status.in'            => 'status_in',
        'points_reward.number' => 'points_reward_number',
        'points_reward.egt'    => 'points_reward_egt',
        'user_id.require'      => 'user_id_required',
        'user_id.number'       => 'user_id_number',
        'vip_id.require'       => 'vip_level_id_required',
        'vip_id.number'        => 'vip_level_id_number',
        'record_id.require'    => 'record_id_required',
        'record_id.number'     => 'record_id_number',
    ];

    // Add scenario
    public function sceneAdd()
    {
        return $this->only(['name', 'icon', 'price', 'duration', 'exclusive_content', 'description', 'status', 'points_reward']);
    }

    // Edit scenario
    public function sceneEdit()
    {
        return $this->only(['id', 'name', 'icon', 'price', 'duration', 'exclusive_content', 'description', 'status', 'points_reward']);
    }

    // Status update scenario
    public function sceneStatus()
    {
        return $this->only(['id', 'status']);
    }

    // Set user VIP scenario
    public function sceneSetUserVip()
    {
        return $this->only(['user_id', 'vip_id', 'duration']);
    }

    // Cancel user VIP scenario
    public function sceneCancelUserVip()
    {
        return $this->only(['record_id']);
    }
}